package com.asset.dispoal.roleMenu.service;

import com.asset.dispoal.roleMenu.api.GbRoleMenuService;
import com.asset.dispoal.roleMenu.domain.db.entity.GbRoleMenuDo;
import com.asset.dispoal.roleMenu.domain.db.mapper.GbRoleMenuMapper;
import com.asset.dispoal.roleMenu.dto.GbRoleMenuRequest;
import com.asset.dispoal.roleMenu.service.converter.GbRoleMenuConverter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

/**
 * 角色菜单表服务实现类
 *
 * @author: mhuang
 * @date: 2022-03-02 14:57:47
 */
@Service
public class GbRoleMenuServiceImpl implements GbRoleMenuService {

    @Autowired
    private GbRoleMenuMapper gbRoleMenuMapper;

    @Override
    @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
    public void insert(GbRoleMenuRequest gbRoleMenuRequest) {
        final GbRoleMenuDo gbRoleMenuDo = GbRoleMenuConverter.INSTANCE.reqToDo(gbRoleMenuRequest);
        gbRoleMenuMapper.delete(gbRoleMenuDo.getRoleId());
        gbRoleMenuMapper.insert(gbRoleMenuDo);
    }


}